const bcrypt = require("bcryptjs");

const encrypt = (plaintext) => {
  const salt = bcrypt.genSaltSync(10);
  const hashedText = bcrypt.hashSync(plaintext, salt);
  return hashedText;
};

const correct = (plaintext, ciphertext) => {
  return bcrypt.compareSync(plaintext, ciphertext);
};

module.exports.encrypt = encrypt;
module.exports.correct = correct;
